<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>申请成为商家</title>
    <!-- jquery -->
    <script src="../js/jquery.min.js"></script>
    <!-- bootstrap -->
    <script src="../js/bootstrap3/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="../js/bootstrap3/css/bootstrap.css"/>
    <!-- bootstrap table -->
    <script src="../js/bootstrap-table/bootstrap-table.js"></script>
    <link rel="../js/bootstrap-table/bootstrap-table.css"/>
    <script src="../js/bootstrap-table/locale/bootstrap-table-zh-CN.js"></script>
    <!-- bootstrap 时间 -->
    <script src="../js/bootstrap-datetimepicker/js/bootstrap-datetimepicker.js"></script>
    <script src="../js/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
    <link rel="stylesheet" href="../js/bootstrap-datetimepicker/css/bootstrap-datetimepicker.css">
    <!-- bootstrap 弹框 -->
    <script src="../js/bootstrap-bootbox/bootbox.js"></script>
    <!-- 图片上传 -->
    <script src="../js/bootstrap-fileinput/js/fileinput.js"></script>
    <script src="../js/bootstrap-fileinput/js/locales/zh.js"></script>
    <link rel="stylesheet" href="../js/bootstrap-fileinput/css/fileinput.css">
</head>
<body>
<br>
<br>
<br><br>
<div class="container-fluid">
    <form class="form-horizontal" id="productForm">
        <div class="form-group">
            <label for="storeName" class="col-sm-2 control-label">店铺名</label>
            <div class="col-sm-4">
                <input type="text"  class="form-control" id="storeName" name="storeName">
            </div>
        </div>
        <div class="form-group">
            <label for="storeImg" class="col-sm-2 control-label">店铺头像</label>
            <div class="col-sm-7">
                <input type="file" multiple class="projectfile" accept="image/*" name="imgfile" id="storeImg">
                <input type="text" id="hadeimg" name="storeImg"  >
            </div>
        </div>
        <div class="form-group">
            <div style="float: right;">
                <button onclick="addProduct()" type="button" class="btn btn-info ">提交</button>
            </div>
        </div>
    </form>
</div>
</body>
<script>

    //新增图片JS
    $('#storeImg').fileinput({
        language: 'zh', //设置语言
        uploadUrl: '../wjs/upload', //上传的地址
        allowedFileExtensions: ['jpg', 'gif', 'png'],//接收的文件后缀
        showUpload: true, //是否显示上传按钮
        showCaption: false,//是否显示标题
        browseClass: "btn btn-primary", //按钮样式
        maxFileCount: 1, //表示允许同时上传的最大文件个数
        enctype: 'multipart/form-data',
        validateInitialCount:true,
        previewFileIcon: "<i class='glyphicon glyphicon-king'></i>",
        msgFilesTooMany: "选择上传的文件数量({n}) 超过允许的最大数值{m}！",
    }).on('fileuploaded', function(event, data, previewId, index) {
        var imgval = data.response.img;
        //隐藏图片ID
        $('#hadeimg').val(imgval);
    });

    function addProduct(){
        $.ajax({
            url:"../wjs/saveStore",
            type:"post",
            data:$("#productForm").serialize(),
            success:function(data){
                if(data.code != 0){
                    bootbox.alert({
                        message:data.msg,
                        size:'small'
                    })
                }else{
                    alert(data.msg)
                }
            }
        })
    }

</script>
</body>
</html>


